﻿using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static HardToolApp.Model.GpioModel;
using static HardToolApp.Model.PwmModel;

namespace HardToolApp.Model
{
    public class OrderModel:ObservableObject
    {
        Peripheral _cmd;
        public Peripheral cmd { get { return _cmd; } set { SetProperty(ref _cmd, value); } }
        CommCmd _cmdType;
        public CommCmd CmdType { get { return _cmdType; } 
            set {
                SetProperty(ref _cmdType, value);
                switch (_cmdType)
                {
                    case CommCmd.COMM_UART:
                        if(cmd is UartModel)
                        {
                            break;
                        }
                        cmd = new UartModel(); break;
                    case CommCmd.COMM_IIC_MASTER:
                        if (cmd is IICMasterModel)
                        {
                            break;
                        }
                        cmd = new IICMasterModel(); break;
                    case CommCmd.COMM_IIC_SLAVE:
                        if (cmd is IICSlaveModel)
                        {
                            break;
                        }
                        cmd = new IICSlaveModel(); break;
                    case CommCmd.COMM_SPI_MASTER:
                        if (cmd is SPIMasterModel)
                        {
                            break;
                        }
                        cmd = new SPIMasterModel(); break;
                    case CommCmd.COMM_SPI_SLAVE:
                        if (cmd is SPISlaveModel)
                        {
                            break;
                        }
                        cmd = new SPISlaveModel(); break;
                    case CommCmd.COMM_GPIO:
                        if (cmd is GPIO)
                        {
                            break;
                        }
                        cmd = new GPIO(); break;
                    case CommCmd.COMM_PWM:
                        if (cmd is PWM)
                        {
                            break;
                        }
                        cmd = new PWM(); break;
                }
            } 
        }
       
    }
}
